package com.salesys.gr.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.salesys.gr.util.DbUtil;
import com.salesys.tony.domain.Conver;

public class ConverDao {
	// 从积分来源查询积分比率
	public String queryMarkPercentFromMarkSource(String markSource) {
		String markPercent = null;
		String sql = "select `markpercent` from `sale_conver` where `marksource`=?";
		DbUtil.getConnection();
		DbUtil.setPerpareStatement(sql);
		DbUtil.setPrepareStatementString(1, markSource);
		DbUtil.queryPrepareStatement();
		ResultSet rs = DbUtil.getResultSet();
		try {
			if (rs.next()) {
				markPercent = rs.getString("markpercent");
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		DbUtil.close();
		return markPercent;
	}

	// 修改积分比率
	public int modifyMarkPercent(Conver con) {
		String sql = "update `sale_conver` set `markpercent`=? where `marksource`=?";
		DbUtil.getConnection();
		DbUtil.setPerpareStatement(sql);
		DbUtil.setPrepareStatementString(1, con.getMarkpercent());
		DbUtil.setPrepareStatementString(2, con.getMarksource());
		DbUtil.updatePrepareStatement();
		int affectRow = DbUtil.getAffectRow();
		DbUtil.close();
		return affectRow;
	}
}
